package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    /**
     *
     *获取当前用户姓名
     * @return
     */
    @GetMapping("/getLoginUsername")
    public Result getLoginUsername(Authentication authentication) {
        String username = authentication.getName();
        return new Result(true, MessageConstant.GET_USERNAME_SUCCESS,username);
    }
}
